home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
bc_ti.zip
/
TI730.ASC
< prev
next >
Wrap
Text File
|
1992-02-25
|
14KB
|
463 lines
PRODUCT : Borland C++ NUMBER : 730
VERSION : 2.0
OS : DOS
DATE : February 25, 1992 PAGE : 1/7
TITLE : Example Source Code for TEMC Filter
/*
EXAMPLE SOURCE CODE FOR TEMC FILTER
TEMC2MSG.C
TEMC2Msg - output filter to Turbo C++ IDE message window
This filter accepts input through the standard input
stream, converts it and outputs it to the standard
output stream. The streams are linked through pipes,
such that the input stream is the output from the
assembler being invoked, and the output stream is
connected to the message window of the Turbo C++ IDE,
ie. temc fname configname | temc2msg | Turbo C++
message window
Compile using Turbo C++ in the LARGE memory model
tcc -ml temc2msg
*/
#include <dir.h>
#include <dos.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <alloc.h>
#include <io.h>
#include <ctype.h>
#include "filter.h"
#define TRUE (1 == 1)
#define FALSE !(TRUE)
/* Turbo TEMC text for conversion */
char TemcWarningTxt[] = "Warning ";
char TemcErrorTxt[] = "Error ";
char TemcFatalTxt[] = "Fatal ";
char CurFile[MAXPATH]; /* Current file in message
window */
unsigned BufSize, /* Size of internal working
buffer */
CurBufLen; /* Buffer space in use */
char *InBuffer, /* Input buffer */
PRODUCT : Borland C++ NUMBER : 730
VERSION : 2.0
OS : DOS
DATE : February 25, 1992 PAGE : 2/7
TITLE : Example Source Code for TEMC Filter
*OutBuffer, /* Output buffer */
*CurInPtr, /* current character in input
buffer */
*CurOutPtr, /* current character in output*/
*LinePtr; /* pointer to the current
character in the input
buffer*/
int (*processor)(char *); /* function pointer used to call
the appropriate conversion
routine */
char Line[133]; /* static buffer to store line
most recently input */
long int InOff; /* position in actual input
stream */
char EndMark; /* Used to output end of data to
message
window */
/*************************************************************************
Function : NextChar
Parameters: none
Returns : next character in input buffer or 0 on end of file
Input from the standard input stream is buffered in a global
buffer InBuffer which is allocated in function main. The
function will return the next character in the buffer, reading
from the input stream when the buffer becomes empty.
**********************************************************************/
char NextChar(void)
{
if (CurInPtr < InBuffer+CurBufLen) /* if buffer is not empty*/
{
return *(CurInPtr++); /* return next character */
}
else
{
CurInPtr = InBuffer; /* reset pointer to front
of buffer */
lseek(0,InOff,0); /* seek to the next section
for read */
InOff += BufSize; /* increment pointer to
next block */
if ((CurBufLen = read(0,InBuffer,BufSize)) !=0)
PRODUCT : Borland C++ NUMBER : 730
VERSION : 2.0
OS : DOS
DATE : February 25, 1992 PAGE : 3/7
TITLE : Example Source Code for TEMC Filter
return NextChar(); /* recursive call merely
returns first character
in buffer after read */
return 0; /* return 0 on end of
file*/
}
}
/*************************************************************************
Function : flushOut
Parameter : Size The number of characters to be written out
Returns : nothing
Strings to be sent to the message window are buffered in a buffer
called OutBuffer. A call to this function will write out Size
bytes from OutBuffer to the standard output stream and resets the
output buffer pointer to the beginning of the buffer. The output
buffer is considered empty after a call to this function.
***********************************************************************/
void flushOut(unsigned Size)
{
if (Size != 0) /* don't flush an empty buffer*/
{
CurOutPtr = OutBuffer; /* reset pointer to beginning of
buffer */
lseek(1,0,2); /* seek output stream to end */
write(1,OutBuffer,Size); /* write out Size bytes */
}
}
/************************************************************************
Function : Put
Parameters: S pointer to bytes being put into output buffer
Len number of bytes to be put in output buffer
Returns : nothing
Put places bytes into OutBuffer so they may be later flushed out
into the standard output stream.
***********************************************************************/
void Put(char *S,int Len)
{
int i;
PRODUCT : Borland C++ NUMBER : 730
VERSION : 2.0
OS : DOS
DATE : February 25, 1992 PAGE : 4/7
TITLE : Example Source Code for TEMC Filter
for (i = 0; i < Len; i++)
{
*CurOutPtr++ = S[i]; /* place byte in buffer */
if (CurOutPtr >= OutBuffer+BufSize)/* if buffer overflows*/
flushOut(BufSize); /* flush the buffer */
}
}
/*************************************************************************
Function : ProcessLine
Parameters: Line a pointer to the current line of characters to
process
Returns : 1 if line is a Turbo Assembler line
0 if line is not
Process through a line of input to determine if it is a Turbo
Assembler output line and convert it to information for the Turbo
C++ message window.
Turbo Assembler lines which are in need of conversion are of the
form:
message-type source-file(LINE #) message-text
where type is one of: Warning, Error
TASM lines are identified by the first portion of text. If
warning, error or fatal is determined at the outset, text is
output from there as it is scanned. Any incorrect configuration
will simply abort the scanning of the rest of the line.
**********************************************************************/
int ProcessLine(char *Line)
{
char Type;
unsigned i;
char *s;
char fn[MAXPATH];
/* don't try to process a NULL line */
if (Line[0] == 0)
return 0;
/* check for temc type tags */
PRODUCT : Borland C++ NUMBER : 730
VERSION : 2.0
OS : DOS
DATE : February 25, 1992 PAGE : 5/7
TITLE : Example Source Code for TEMC Filter
if (strncmp(Line,TemcWarningTxt,strlen(TemcWarningTxt))== 0)
memmove(Line,&Line[strlen(TemcWarningTxt)],strlen(Line));
e